
package com.jida.hadoop.mr.user7;
 
 
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
 
import java.io.IOException;
 
/**
 * 用户产品统计：统计用户访问的产品信息(PV)
      {产品ID,用户ID,PV(访问量),产品类型}
 */
public class MapperDxProStatistic extends Mapper<LongWritable,Text,Text,IntWritable>{
    private Text k2 = new Text();
    private IntWritable v2 = new IntWritable(1);
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String[] ss = value.toString().split("\\|");
        k2.set(ss[2]+","+ss[0]+","+ss[1]);//产品ID，用户ID，产品类型
        context.write(k2,v2);//({产品ID，用户ID，产品类型},1)
    }
}
